package com.mall.activiti.controller;

import com.central.common.model.Result;
import com.mall.activiti.Request.AddXMLReq;
import com.mall.activiti.service.ActivitiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


/**
 * @author dingding.wang
 * @apiNote  页面交互接口
 */
@RestController
@RequestMapping("/activiti")
public class ActivitiController {

    @Autowired
    private ActivitiService activitiService;

    /**
     * 上传bpmn格式或者zip格式的流程图
     * @param processFile
     * @param processName
     * @return
     */
    @PostMapping("/uploadFileAndDeployment")
    public Result<Object> uploadFileAndDeployment(@RequestParam("processFile") MultipartFile processFile,
                                          @RequestParam(value = "processName", required = false) String processName) {
        return Result.succeed(activitiService.uploadFileAndDeployment(processFile,processName));
    }

    /**
     * 上传xml格式的流程图
     * @param addXMLRequest
     * @return
     */
    @PostMapping("/postBPMNAndDeployment")
    public Result<Object> postBPMNAndDeployment(@RequestBody AddXMLReq addXMLRequest) {
        return Result.succeed(activitiService.postBPMNAndDeployment(addXMLRequest));
    }
}
